<template>
  <div name="InteractionDemand">
    <div class="s-InteractionDemand">
      <el-form ref="form" :rules="rules" :model="form" label-width="80px">
        <el-form-item label="需求标题" prop="name">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="需求类型" prop="DemandType">
          <el-radio-group v-model="form.DemandType">
            <el-radio :label="1">数据</el-radio>
            <el-radio :label="2">应用</el-radio>
            <el-radio :label="3">接口</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="功能描述" prop="synopsis">
          <el-input v-model="form.synopsis"></el-input>
        </el-form-item>
        <el-form-item label="数据领域" prop="dataField">
          <el-input v-model="form.dataField"></el-input>
        </el-form-item>
        <el-form-item label="用户类型" prop="UserType">
          <el-radio-group v-model="form.UserType">
            <el-radio :label="1">学生</el-radio>
            <el-radio :label="2">机关</el-radio>
            <el-radio :label="3">事业单位</el-radio>
            <el-radio :label="4">社会团体</el-radio>
            <el-radio :label="5">企业</el-radio>
            <el-radio :label="6">其他</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="数据格式" prop="DataType">
          <el-radio-group v-model="form.DataType">
            <el-radio :label="1">csv</el-radio>
            <el-radio :label="2">pdf</el-radio>
            <el-radio :label="3">xml</el-radio>
            <el-radio :label="4">xls</el-radio>
            <el-radio :label="5">其他</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="用      途" prop="PurposeType">
          <el-radio-group v-model="form.PurposeType">
            <el-radio :label="1">学习</el-radio>
            <el-radio :label="2">研究</el-radio>
            <el-radio :label="3">商业</el-radio>
            <el-radio :label="4">公益</el-radio>
            <el-radio :label="5">教育</el-radio>
            <el-radio :label="6">其他</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="职能部门" prop="departmentValue">
          <el-select v-model="form.departmentValue" placeholder="请选择">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <p class="submit">
            <el-button @click="submit('form')">提交</el-button>
          </p>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  name: "InteractionDemand",
  data() {
    return {
      form: {
        name: "",
        DemandType: "",
        synopsis: "",
        dataField: "",
        UserType: "",
        DataType: "",
        PurposeType: "",
        departmentValue: "",
      },
      rules: {
        name: [
          { required: true, message: "请输入需求标题", trigger: "blur" },
          { min: 3, max: 10, message: "长度在 3 到 10 个字符", trigger: "blur" },
        ],
        DemandType: [{ required: true, message: "请选择需求类型", trigger: "change" }],
        synopsis: [
          { required: true, message: "请输入功能描述", trigger: "blur" },
          { min: 3, max: 10, message: "长度在 3 到 10 个字符", trigger: "blur" },
        ],
        dataField: [
          { required: true, message: "请输入数据领域", trigger: "blur" },
          { min: 3, max: 10, message: "长度在 3 到 10 个字符", trigger: "blur" },
        ],
        UserType: [{ required: true, message: "请选择用户类型", trigger: "change" }],
        DataType: [{ required: true, message: "请选择用户类型", trigger: "change" }],
        PurposeType: [{ required: true, message: "请选择用 途", trigger: "change" }],
        departmentValue: [{ required: true, message: "请选择职能部门", trigger: "change" }],
      },
      options: [
        {
          value: "市教育局",
          label: "市教育局",
        },
        {
          value: "市科技局",
          label: "市科技局",
        },
        {
          value: "市财政局",
          label: "市财政局",
        },
        {
          value: "市司法局",
          label: "市司法局",
        },
        {
          value: "市民政局",
          label: "市民政局",
        },
      ],
    };
  },
  methods: {
    submit(form) {
      this.$refs[form].validate(valid => {
        if (valid) {
          alert(JSON.stringify(this.form));
          // this.$refs[form].resetFields();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>
